package com.erhuogo.dao.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.erhuogo.dao.AdminDao;
import com.erhuogo.entity.Admin;

/**
 * 管理员Dao的实现类
 * @author aibinxiao
 * @date 2016年10月26日 上午11:38:58
 */
public class AdminDaoImpl extends HibernateDaoSupport implements AdminDao {
	// 日志
	private static Logger logger = LoggerFactory.getLogger(AdminDaoImpl.class);

	/**
	 * 1.管理员登陆Dao实现类
	 */
	@Override
	public Admin login(String loginName, String password) {
		String hql = "from Admin where loginName = ? and password = ?";
		List<Admin> list = this.getHibernateTemplate().find(hql, loginName, password);
		if (list != null && list.size() > 0) {
			logger.info("用户名登陆" + list.get(0));
			return list.get(0);
		}
		return null;
	}
}
